<template>
  <div>
    <p>商品清单如下：</p>
    <ul>
      <li v-for="(obj, index) in goodsList" :key="index">
        <p>{{ obj.shopName }}{{ obj.price }}元/份</p>
      </li>
    </ul>
    <p>请选择购买数量</p>
    <practise6
      v-for="(obj, index) in goodsList"
      :key="index"
      :arr="obj"
    ></practise6>
    <p>总价为：{{ sumaaa }}</p>
  </div>
</template>

<script>
import Practise6 from "./components/practise6.vue";
export default {
  components: {
    Practise6,
  },
  data() {
    return {
      goodsList: [
        {
          shopName: "可比克薯片",
          price: 5.5,
          count: 0,
        },
        {
          shopName: "草莓酱",
          price: 3.5,
          count: 0,
        },
        {
          shopName: "红烧肉",
          price: 55,
          count: 0,
        },
        {
          shopName: "方便面",
          price: 12,
          count: 0,
        },
      ],
    };
  },
  computed: {
    sumaaa() {
      return this.goodsList.reduce(
        (total, obj) => total + obj.price * obj.count,
        0
      );
    },
  },
};
</script>

<style>
</style>